#pragma once

#include"Common.h"

class ProductionTask
{
public:
	enum State{Undefined , WaitForCanMake , Asigned , Depart , Morphing , Done , Dead};
	enum Type{DoNothing , CreateUnit , Build , Research , Upgrade};
	//--
	ProductionTask()
		:_unitType(UnitTypes::None),
		_techType(TechTypes::None),
		_upgradeType(UpgradeTypes::None),
		_baseIndex(-1),
		_state(Undefined),
		_type(DoNothing)
	{
	}
	ProductionTask(const UnitType& unitType)
		:_unitType(unitType),
		_techType(TechTypes::None),
		_upgradeType(UpgradeTypes::None),
		_baseIndex(-1),
		_state(WaitForCanMake),
		_type(CreateUnit)
	{
	}
	ProductionTask(const UnitType& unitType , const int& baseIndex)
		:_unitType(unitType),
		_techType(TechTypes::None),
		_upgradeType(UpgradeTypes::None),
		_baseIndex(baseIndex),
		_state(WaitForCanMake),
		_type(Build)
	{
	}
	ProductionTask(const TechType& techType)
		:_unitType(UnitTypes::None),
		_techType(techType),
		_upgradeType(UpgradeTypes::None),
		_baseIndex(-1),
		_state(WaitForCanMake),
		_type(Research)
	{
	}
	ProductionTask(const UpgradeType& upgradeType)
		:_unitType(UnitTypes::None),
		_techType(TechTypes::None),
		_upgradeType(upgradeType),
		_baseIndex(-1),
		_state(WaitForCanMake),
		_type(Upgrade)
	{
	}
	Type GetTaskType() const
	{
		return _type;
	}
	UnitType GetBuildType() const
	{
		return _unitType;
	}
	TechType GetTechType() const
	{
		return _techType;
	}
	UpgradeType GetUpgradeType() const
	{
		return _upgradeType;
	}
	int GetBaseIndex() const
	{
		return _baseIndex;
	}
	State GetState() const
	{
		return _state;
	}
	void SetState(State newState)
	{
		_state = newState;
	}
	string GetName() const
	{
		if(_type == CreateUnit || _type == Build)
		{
			return _unitType.getName();
		}
		else if(_type == Research)
		{
			return _techType.getName();
		}
		else if(_type == Upgrade)
		{
			return _upgradeType.getName();
		}
	}
private:
	UnitType _unitType;
	TechType _techType;
	UpgradeType _upgradeType;
	int _baseIndex;
	State _state;
	Type _type;
};